package com.demo.widget.meis;

import com.demo.widget.BaseAbility;
import com.demo.widget.ResourceTable;
import com.meis.widget.praise.BezierPraiseAnimator;
import com.meis.widget.praise.BezierPraiseView;
import ohos.aafwk.content.Intent;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.Image;
import ohos.agp.components.LayoutScatter;

/**
 * Created by wenshi on 2018/7/11.
 * Description
 */
public class MeiPraiseAbility extends BaseAbility {
    private Image mIvPraise;
    private BezierPraiseAnimator mPraiseAnimator;
    private BezierPraiseView bezierpraiseview;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        ComponentContainer root = (ComponentContainer) LayoutScatter.getInstance(getContext())
                .parse(ResourceTable.Layout_mei_praise_ability, null, false);
        setUIContent(root);
        DependentLayout container = (DependentLayout) findComponentById(ResourceTable.Id_container);
        bezierpraiseview = (BezierPraiseView) findComponentById(ResourceTable.Id_bezierpraiseview);
        mPraiseAnimator = new BezierPraiseAnimator(this, container);
        mIvPraise = (Image) findComponentById(ResourceTable.Id_iv_praise);
        mIvPraise.setClickedListener(component -> mPraiseAnimator.startAnimation(mIvPraise));
    }

    @Override
    protected void onBackPressed() {
        bezierpraiseview.stop();
        super.onBackPressed();
    }
}
